<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>动态参数</title>
</head>

<body>
  <script>
    function getSum() {
      // arguments动态参数
      // 使用场景:不知道用户调用时传几个参数,动态获取参数
      // 特点:只存在于函数里面
      // 是一个伪数组
      console.log(arguments);
      let sum = 0
      for (let i = 0; i < arguments.length; i++) {
        sum += arguments[i]
      }
      console.log(sum);
    }
    getSum(2, 3)
    getSum(2, 3.5, 3)
    getSum(2, 3, 4, 5, 6, 4)
    getSum(2, 3, 7, 8, 6, 4, 9)
  </script>
</body>

</html>